#!/bin/sh

command sh -c 'command apt-get -y install lsb-release gnupg;
if [ -z "$(command grep "Tor system setup" "/etc/sysctl.conf")" ]; then
  command echo "# Tor system setup.
fs.file-max=100000" >> "/etc/sysctl.conf"
  command sysctl -p
fi
DEBIAN_VERSION=$(command lsb_release -cs);
command echo "# TOR for ${DEBIAN_VERSION}
deb http://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" \
 > "/etc/apt/sources.list.d/torproject.list";
command gpg --keyserver keys.gnupg.net --recv 886DDD89;
command gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | command apt-key add -;
command apt-get update;
command apt-get -y install privoxy tor curl;
command echo "forward-socks4a / localhost:9050 ." >> "/etc/privoxy/config";
command sed -i -e "s/^\(listen-address[ \t]*\)[^:]*/\1/" "/etc/privoxy/config";
command sed -i -e "s/^\(debug[ \t]*.*\)/#\1/" "/etc/privoxy/config";
/etc/init.d/privoxy restart'